// import EventBus from '../../core/event-bus';
import { Alert } from 'react-native';

export const emitError = () => async function fn(m, next) {
  if (m.res) {
    const { success, message } = m.res.data;
    if (!success) {
      // EventBus.$emit('error', msg);
      Alert.alert(
        '出错啦',
        message,
        [{ text: '确定', onPress: () => console.log('Cancel Pressed'), style: 'cancel' }],
        { cancelable: false }
      );
      throw new Error(message);
    }
    next();
  }
};
